<%@ page pageEncoding="UTF-8"%>
<%@ taglib prefix="isperp" uri="/WEB-INF/tlds/isperp.tld"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>

<table class="form-table">

	<tr>
		<td colspan="4">
			<div class="header">
				<h3>分类信息</h3>
			</div>
		</td>
	</tr>
	<tr>
		<td class="td1">事件分类：</td>
		<td class="td2" colspan="3"><form:hidden
				path="icdCategoryId" /> <isperp:treeSelector width="500" asyncLoad="false"
				displayColumn="name" displayValueCssStyle="width:249px"
				url="incident/category/getTree" afterSelected="changeIcdCategory(ids,names,treeNode)"
				autocompleteUrl="incident/category/list"
				afterSelectEmpty="clearIcdCategory();" id="icdCategorySelector"
				name="icdCategoryName" displayValue="${model.icdCategoryName }"
				valueControlId="icdCategoryId" displayValueCssClass="required"></isperp:treeSelector>
		</td>
	</tr>
	<tr>

		<td class="td1">紧急度：</td>
		<td class="td2" colspan="3"><isperp:dictSelector
				typeCode="INCIDENT_URGENCY" name="urgencyName" id="urgencyName"
				hasEmptyValue="false" dictCssClass="required" dataWidth="260px"
				onchangeFunc="resetPriorityName()"
				selectedValue="${model.urgencyName }"></isperp:dictSelector></td>
	</tr>
	<tr>
		<td class="td1">影响度：</td>
		<td class="td2" colspan="3"><isperp:dictSelector
				typeCode="INCIDENT_EFFECT" name="effectName" id="effectName"
				hasEmptyValue="false" dictCssClass="required" dataWidth="260px"
				onchangeFunc="resetPriorityName()"
				selectedValue="${model.effectName }"></isperp:dictSelector>
		</td>
	</tr> 
	<tr>
		<td class="td1">优先级：</td>
		<td class="td2" colspan="3"><isperp:dictSelector
				typeCode="INCIDENT_PRIORITY" name="priorityName" id="priorityName"
				hasEmptyValue="false" dictCssClass="required" dataWidth="260px"
				selectedValue="${empty model.priorityName?'三级':model.priorityName }"></isperp:dictSelector>
		</td>
	</tr>

	
	 <tr style="">
		<td class="td1">处理方式：</td>
		<td class="td2" colspan="3"><form:radiobutton path="dealType"
				onchange="changesway(1)" value="1" id="dealType_1" /><label
			for="dealType_1">直接处理</label> <form:radiobutton path="dealType"
				onchange="changesway(2)" value="2" id="dealType_2" /><label
			for="dealType_2">分派处理</label>
		</td>
	</tr> 

	 <tr id="supporter_tr2line" style="margin-bottom: 15px">
		<td class="td1">支持人员：</td>
		<td class="td2" colspan="3"><form:hidden path="supporterId" /> <isperp:departmentUser
				displayValue="${model.supporterName }" valueControlId="supporterId"
				displayValueStyle="width:250px" idFieldName="name"
				 id="supporterName" ifIncludeNoRoleUser="false"
				name="supporterName" multiselect="false"
				displayValueCssClass="required"></isperp:departmentUser></td>
	</tr> 

</table>

<div id="projectMemberGrid_div">
	<isperp:grid url="" datatype="local" rowNum="10"
		postData="categoryId:function() { return '';}" 
		multiselect="false" showSearchbar="false" gridId="projectMemberGrid"
		showToolbar="false" height="auto" gridTitle="${pageTitle}"
		cusFormatterActions="false"
		ondbClickRowEvent="projectMemberGrid_OndbClick(rowid);">
		<isperp:column name="id" title="id" hidden="true"></isperp:column>
		<isperp:column name="fullname" title="姓名" width="50">
		</isperp:column>
		<isperp:column name="mobile" title="手机" width="70">
		</isperp:column>
		<isperp:column name="tel" title="座机"  width="70">
		</isperp:column>
		<isperp:column name="process_count" title="任务数" width="50">
		</isperp:column>
		<isperp:column name="position_name" title="职务" width="60">
		</isperp:column>
		<isperp:column name="duty" title="值班状态" width="70">
		</isperp:column>
		<isperp:column name="name" title="name" hidden="true">
		</isperp:column>
		<isperp:column name="" title="操作" isFormatterFun="true"
			formatter="return projectMemberGrid_ActionFormatter(cellvalue,rowObject);"
			align="left" width="50">
		</isperp:column> 
	</isperp:grid>
</div>

<script type="text/javascript">
	function getProjectId() {
		return $("#incidentProjectId").val();
	}

	$(function() {
		var cateId = $("#icdCategoryId").val();
		if (cateId) {
			$.get("incident/category/getOne?id=" + cateId, function(data) {
				$("#performancePoint").val(data.performancePoint);
				var modelEdit = "${modelEdit}";
				if (modelEdit != "true") {
					$("#incidentType").val(data.incidentType);
					$("#incidentType").trigger('chosen:updated');
				}
			});
			searchCategoryMember(cateId);
			//searchCategoryDandang(cateId);
		}
	});
	
	function changeIcdCategory(ids,names,tn)
	{
	   var areAuto=tn.areauto;
	   
	   searchCategoryMember(ids,areAuto);
	}
	function searchCategoryMember(cateId,areAuto)
	{
	      projectMemberGrid.jqGrid.setGridParam({
			url : "incident/category/categoryRelateMemberUserList?categoryId=" + cateId
		   });
		   projectMemberGrid.search();
		   $.ajax({
		     url:"incident/category/categoryRelateMemberUserList?categoryId=" + cateId,
		     success:function(data)
		     {
		        var names="";
		        var ids="";
		        for(var i=0;i<data.length;i++)
		        {
		          names+=","+data[i]["fullname"];
		          ids+=","+data[i]["user_name"];
		        }
		        names=names.substring(1);
		        ids=ids.substring(1);
		        $("#supporterId").val(ids);
		        $("#supporterName").val(names);
		     }
		   })
	}

	function clearIcdCategory() {
		$("#icdCategoryId").val("");
		$("#icdCategorySelector").val("");
	}
	function getAddressByLoactionDiv(cellValue, rowObject) {
		if (rowObject.longitude && rowObject.latitude && rowObject.longitude != "" && rowObject.latitude != "") {
			var location = (rowObject.latitude + "") + "," + (rowObject.longitude + "");
			return "<div class='location_div' style='white-space:pre-wrap' id='row_"+rowObject.id+"' data-id='"+rowObject.id+"' data-location='"+location+"'>加载中...</div>";
		}
		return "";
	}
	function projectMemberGrid_ActionFormatter(cellvalue, rowObject) {
		return "<a href='javascript:void(0);' onclick='projectMemberGrid_OndbClick(\"" + rowObject.id + "\")'>[选择]</a>";
	}
	function projectMemberGrid_OndbClick(rowid) {
		var rowD = projectMemberGrid.getRowData(rowid);
		$("#supporterId").val(rowD.name);
		$("#supporterName").val(rowD.fullname);
	}
	var searchProjectMember = function() {
	    var projectId=$("#incidentProjectId").val();
	    if(projectId)
	    {
	       projectMemberGrid.jqGrid.setGridParam({
			url : "project/member/projectMemberUserList?projectId=" + projectId
		   });
		   projectMemberGrid.search();
	    }
		
	};
</script>